<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>document.querySelector</title>
    <style>
        .myhead{
             color: red;
         }
    </style>
</head>
<body>
<div>
    <p class="myhead">我是myhead</p>
    <p>我没有任何类</p>
</div>
<div>
    <p class="myhead">我是myhead2</p>
    <p>我没有任何类</p>
</div>
</body>
<script>
    nodelist =  document.querySelectorAll('div > p.myhead')
    nodelist[0].innerHTML='被修改后的元素1'
    nodelist[1].innerHTML='被修改后的元素2'
</script>
</html>